Change in openvpn[master]: Do not stop reading from file/uri when OPENSSL_STORE_load() returns e...
A message that is not in the archive (sent off-list or not yet received): gerrit.1726024745000.I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3@...2715...
Attention is currently required from: flichtenheld, plaisthos.
Hello plaisthos, flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
to review the following change.
Change subject: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
......................................................................
Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
OPENSSL_STORE_load() can error and return NULL even when the file or URI still has readable objects left.
Fix by iterating until OPENSSL_STORE_eof(). Also clear such errors to avoid misleading messages printed at the end by crypto_print_openssl_errors().
---
M src/openvpn/ssl_openssl.c
1 file changed, 42 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/742/1
src/openvpn/ssl_openssl.c +42 -5
@@ -813,6 +813,15 @@ }return 0 ; } + +static void +clear_ossl_store_error (OSSL_STORE_CTX *store_ctx) +{ +if (OSSL_STORE_error (store_ctx)) + { +ERR_clear_error (); + } +}#endif /* defined(HAVE_OPENSSL_STORE_API) */ /**
@@ -864,7 +873,19 @@ { goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1099,7 +1120,19 @@ goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached. +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1120,9 +1153,14 @@OSSL_STORE_INFO_free (info);/* iterate through the store and add extra certificates if any to the chain */ - info =OSSL_STORE_load (store_ctx); -while (info && !OSSL_STORE_eof (store_ctx)) +while (!OSSL_STORE_eof (store_ctx)) { + info =OSSL_STORE_load (store_ctx); +if (!info) + { +clear_ossl_store_error (store_ctx); +continue ; + } x =OSSL_STORE_INFO_get1_CERT (info);if (x &&SSL_CTX_add_extra_chain_cert (tls_ctx->ctx, x) !=1 ) {
@@ -1131,7 +1169,6 @@break ; }OSSL_STORE_INFO_free (info); - info =OSSL_STORE_load (store_ctx); } end:
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Gerrit-Change-Number: 742
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, selvanair.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/742?usp=email )
Change subject: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
......................................................................
Patch Set 1: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Gerrit-Change-Number: 742
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Wed, 11 Sep 2024 10:37:22 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Attention is currently required from: flichtenheld, selvanair.
plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/742?usp=email )
Change subject: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
......................................................................
Patch Set 1:
(1 comment)
Patchset:
PS1:
Thanks I can confirm that this fixes the problem I saw with a pem file containing both key + certificate.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Gerrit-Change-Number: 742
Gerrit-PatchSet: 1
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Attention: selvanair <[email protected]...>
Gerrit-Comment-Date: Wed, 11 Sep 2024 10:37:53 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Gerrit-MessageType: comment
PATCH 1/1 Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
In reply to a message not in the archiveFrom: Selva Nair <[email protected]...>
OPENSSL_STORE_load() can error and return NULL even when the file or URI still has readable objects left.
Fix by iterating until OPENSSL_STORE_eof(). Also clear such errors to avoid misleading messages printed at the end by crypto_print_openssl_errors().
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/742
This mail reflects revision 1 of this Change.
Acked-by according to Gerrit (reflected above):
Arne Schwabe <[email protected]...>
src/openvpn/ssl_openssl.c +42 -5
@@ -813,6 +813,15 @@ }return 0 ; } + +static void +clear_ossl_store_error (OSSL_STORE_CTX *store_ctx) +{ +if (OSSL_STORE_error (store_ctx)) + { +ERR_clear_error (); + } +}#endif /* defined(HAVE_OPENSSL_STORE_API) */ /**
@@ -864,7 +873,19 @@ { goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1099,7 +1120,19 @@ goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached. +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1120,9 +1153,14 @@OSSL_STORE_INFO_free (info);/* iterate through the store and add extra certificates if any to the chain */ - info =OSSL_STORE_load (store_ctx); -while (info && !OSSL_STORE_eof (store_ctx)) +while (!OSSL_STORE_eof (store_ctx)) { + info =OSSL_STORE_load (store_ctx); +if (!info) + { +clear_ossl_store_error (store_ctx); +continue ; + } x =OSSL_STORE_INFO_get1_CERT (info);if (x &&SSL_CTX_add_extra_chain_cert (tls_ctx->ctx, x) !=1 ) {
@@ -1131,7 +1169,6 @@break ; }OSSL_STORE_INFO_free (info); - info =OSSL_STORE_load (store_ctx); } end:
[Openvpn-devel] [PATCH applied] Re: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
Thanks for fixing this so quickly. Now this seems to be an... interesting API to work with... :-)
I do not have something really interesting set up in terms of cert files and storage, so I just did basic client side testing with OSSL 3.x (works).
Your patch has been applied to the master branch
(bugfix, but offending code not in 2.6).
commit e9ad1b31a04799de98f15220eb39225c3d9eaa64
Author: Selva Nair Date: Wed Sep 11 12:49:41 2024 +0200
Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Arne Schwabe <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29187.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#2) to the change originally created by selvanair. ( http://gerrit.openvpn.net/c/openvpn/+/742?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by plaisthos
Change subject: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
......................................................................
Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
OPENSSL_STORE_load() can error and return NULL even when the file or URI still has readable objects left.
Fix by iterating until OPENSSL_STORE_eof(). Also clear such errors to avoid misleading messages printed at the end by crypto_print_openssl_errors().
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29187.html
---
M src/openvpn/ssl_openssl.c
1 file changed, 42 insertions(+), 5 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/42/742/2
src/openvpn/ssl_openssl.c +42 -5
@@ -813,6 +813,15 @@ }return 0 ; } + +static void +clear_ossl_store_error (OSSL_STORE_CTX *store_ctx) +{ +if (OSSL_STORE_error (store_ctx)) + { +ERR_clear_error (); + } +}#endif /* defined(HAVE_OPENSSL_STORE_API) */ /**
@@ -864,7 +873,19 @@ { goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1099,7 +1120,19 @@ goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached. +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1120,9 +1153,14 @@OSSL_STORE_INFO_free (info);/* iterate through the store and add extra certificates if any to the chain */ - info =OSSL_STORE_load (store_ctx); -while (info && !OSSL_STORE_eof (store_ctx)) +while (!OSSL_STORE_eof (store_ctx)) { + info =OSSL_STORE_load (store_ctx); +if (!info) + { +clear_ossl_store_error (store_ctx); +continue ; + } x =OSSL_STORE_INFO_get1_CERT (info);if (x &&SSL_CTX_add_extra_chain_cert (tls_ctx->ctx, x) !=1 ) {
@@ -1131,7 +1169,6 @@break ; }OSSL_STORE_INFO_free (info); - info =OSSL_STORE_load (store_ctx); } end:
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Gerrit-Change-Number: 742
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/742?usp=email )
Change subject: Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
......................................................................
Do not stop reading from file/uri when OPENSSL_STORE_load() returns error
OPENSSL_STORE_load() can error and return NULL even when the file or URI still has readable objects left.
Fix by iterating until OPENSSL_STORE_eof(). Also clear such errors to avoid misleading messages printed at the end by crypto_print_openssl_errors().
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29187.html
---
M src/openvpn/ssl_openssl.c
1 file changed, 42 insertions(+), 5 deletions(-)
src/openvpn/ssl_openssl.c +42 -5
@@ -813,6 +813,15 @@ }return 0 ; } + +static void +clear_ossl_store_error (OSSL_STORE_CTX *store_ctx) +{ +if (OSSL_STORE_error (store_ctx)) + { +ERR_clear_error (); + } +}#endif /* defined(HAVE_OPENSSL_STORE_API) */ /**
@@ -864,7 +873,19 @@ { goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1099,7 +1120,19 @@ goto end; } - info =OSSL_STORE_load (store_ctx); +while (1 ) + { + info =OSSL_STORE_load (store_ctx); +if (info ||OSSL_STORE_eof (store_ctx)) + { +break ; + } +/* OPENSSL_STORE_load can return error and still have usable objects to follow. +* ref: man OPENSSL_STORE_open +* Clear error and recurse through the file if info = NULL and eof not reached. +*/ +clear_ossl_store_error (store_ctx); + }if (!info) { goto end;
@@ -1120,9 +1153,14 @@OSSL_STORE_INFO_free (info);/* iterate through the store and add extra certificates if any to the chain */ - info =OSSL_STORE_load (store_ctx); -while (info && !OSSL_STORE_eof (store_ctx)) +while (!OSSL_STORE_eof (store_ctx)) { + info =OSSL_STORE_load (store_ctx); +if (!info) + { +clear_ossl_store_error (store_ctx); +continue ; + } x =OSSL_STORE_INFO_get1_CERT (info);if (x &&SSL_CTX_add_extra_chain_cert (tls_ctx->ctx, x) !=1 ) {
@@ -1131,7 +1169,6 @@break ; }OSSL_STORE_INFO_free (info); - info =OSSL_STORE_load (store_ctx); } end:
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/742?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I2bfa9ffbd17d0599014d38b2a2fd319766cdb1e3
Gerrit-Change-Number: 742
Gerrit-PatchSet: 2
Gerrit-Owner: selvanair <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged